package com.naizhuai.ui.user.multtype;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.naizhuai.R;
import com.naizhuai.util.DeviceUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import me.drakeet.multitype.ItemViewBinder;

/**
 * @author：lichenxi
 * @date 2018/5/28 15
 * email：525603977@qq.com
 * Fighting
 */
public class SpaceViewBinder extends ItemViewBinder<Space, SpaceViewBinder.ViewHolder> {

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View root = inflater.inflate(R.layout.info_item_space, parent, false);
        return new ViewHolder(root);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull Space space) {
        Context context=holder.itemView.getContext();
        ViewGroup.LayoutParams layoutParams=holder.spaceLine.getLayoutParams();
        layoutParams.height= DeviceUtils.dp2px(context,space.space);
        holder.spaceLine.setLayoutParams(layoutParams);
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.space_line)
        View spaceLine;
        ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
